package com.fubon.wloan.service;

import com.fubon.wloan.pojo.Body;
import com.fubon.wloan.pojo.Expanding;
import com.fubon.wloan.pojo.LoanBasicInfo;
import com.fubon.wloan.pojo.LoanRespBasicInfo;
import com.fubon.wloan.pojo.Resp;
import com.fubon.wloan.repository.LoanBasicInfoRepository;
import com.fubon.wloan.repository.LoanRespBasicInfoRepository;
import com.fubon.wloan.repository.LoanStatusRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;

import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;

@Service
public class ConsumeServiceImpl implements ConsumeService {

    @Value("${forward.host}")
    private String host;

    @Value("${forward.url.saveConsumer}")
    private String urlSaveConsumer;

    @Autowired
    private LoanBasicInfoRepository loanBasicInfoRepository;

    @Autowired
    private LoanRespBasicInfoRepository loanRespBasicInfoRepository;

    @Autowired
    private LoanStatusRepository LoanStatusRepository;

    @Autowired
    private TransactionTemplate transactionTemplate;

    @Autowired
    @Qualifier("jdbcScheduler")
    private Scheduler jdbcSecheduler;

    @Override
    public Mono<Body<LoanBasicInfo, Expanding>> SaveCreditData(Body<LoanBasicInfo, Expanding> body) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Mono<Resp> SendCallbackMsg(Body<LoanBasicInfo, Expanding> body) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Mono<LoanRespBasicInfo> findByReqSn(String reqSn) {
        Mono<LoanRespBasicInfo> resp = Mono.defer(()-> Mono.just(loanRespBasicInfoRepository.findByReqSn(reqSn))).subscribeOn(jdbcSecheduler);
        
        return resp;
    }



    
}